package stream第二遍.demo10;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @author wql
 * @version 1.0
 * @date 2022/11/6 12:51
 */

public class Test {
    public static void main(String[] args) {
        List<Wql> list = new ArrayList<>();
        list.add(new Wql("只因",23,"中"));
        list.add(new Wql("太没",15,"美"));
        list.add(new Wql("giao",20,"俄"));
        list.add(new Wql("只因蛋",6,"意"));
        list.add(new Wql("只因粉",45,"中"));


      //  Set<Wql> collect = list.stream().filter(item -> item.getAge() > 1).filter(item -> item.getName().length() > 2).collect(Collectors.toSet());
       // System.out.println("collect = " + collect);

      //  Map<String, Wql> collect   = list.stream().filter(item -> item.getAge() > 3).filter(item -> item.getCountry() == "中").collect(Collectors.toMap(item -> item.getName(), item -> item));
       // System.out.println("collect = " + collect);

        Map<String, List<Wql>> collect = list.stream().collect(Collectors.groupingBy(item -> item.getCountry()));
        System.out.println("collect = " + collect);
    }
}
class  Wql{
    private String name;
    private Integer age;
    private String country;

    public Wql(String name, Integer age, String country) {
        this.name = name;
        this.age = age;
        this.country = country;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    @Override
    public String toString() {
        return "Wql{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", country='" + country + '\'' +
                '}';
    }
}





